package com.view.jameson.androidrecyclerviewcard;

import android.graphics.Rect;
//import android.support.annotation.NonNull;
//import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class CenterItemDecoration extends RecyclerView.ItemDecoration {

    @Override
    public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);
        Log.e("getItemOffsets", "getItemOffsets");
        RecyclerView.Adapter adapter = parent.getAdapter();
        if (adapter != null) {
            int itemCount = adapter.getItemCount();
            int parentWidth = parent.getWidth();
            int childWidth = view.getWidth();

            int margin = (parentWidth - childWidth) / 2;
//            outRect.left = 30;
//            outRect.right = 40;
            outRect.left = 30;
            outRect.right = 40;
        }
//        int parentWidth = parent.getWidth();
//        int childWidth = view.getWidth();
//        int margin = (parentWidth - childWidth) / 2;
//        outRect.left = 30;
//        outRect.right = 40;
//        outRect.left = 0;
//        outRect.right = 0;
    }
}
